package jfprincesstests.fakes;

import jfuzzyprincepless.agents.INegotiatingAgent;
import jfuzzyprincepless.algorithm.structure.DefaultNegConstruction;
import jfuzzyprincepless.algorithm.structure.services.IWhileService;

import java.util.Arrays;
import java.util.Map;
import java.util.HashMap;

public class FakeWhileNegConstr
	extends DefaultNegConstruction
	implements IWhileService
{
	private Map<INegotiatingAgent, Integer> remainMap =
		new HashMap<INegotiatingAgent, Integer>();

	public FakeWhileNegConstr(
		INegotiatingAgent ... agents
	) {
		super(Arrays.asList(agents));
	}

	@Override
	public boolean isAgentAlive(
		INegotiatingAgent agent
	) {
		int remainSteps = remainMap.get(agent);
		remainSteps--;
		remainMap.put(agent, remainSteps);
		return remainSteps > 0;
	}

	public void setRemaind(INegotiatingAgent agent, int remSteps) {
		remainMap.put(agent, remSteps);
	}
}
